<%--
 *  File:   contactProdPopWindow.jsp
 *  Date		  Author		  Changes
 *  2009-10-24	  awesomewang		  Created
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
	//init param
  	String privilegeCode = "All";
    String strModuleName = "COM";
  	String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>
<iframe name="reloadHandler" style="display:none"></iframe>
<html>
<head>
<title>contactProdPopWindow</title>
<PageFlow:CheckPageFlow pageName="p_contactprod"/>
<%@ include file="/inc/AlertError.inc" %>
<%
  Vector details = (Vector)pageContext.getAttribute("details");
  if(details == null) details = new Vector();
   
  Integer usrid = (Integer)pageContext.getAttribute("usrid");
  if(usrid == null) 
	  usrid = new Integer(0);
  
  
  Integer datacategory = (Integer)pageContext.getAttribute("datacategory");
  if(datacategory == null) datacategory = new Integer(0);

%>

<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<%
	HashMap Cuserinfo = (HashMap)session.getAttribute("userinfo");
   	if (Cuserinfo==null){
   		Cuserinfo = new HashMap();
   	}
   	String strIsFromHomepage1 = "N";
   	if (Cuserinfo.get("isFromHomepage1")!=null ){
   		strIsFromHomepage1 = (String)Cuserinfo.get("isFromHomepage1");
    }    
   	String isview=(String)request.getParameter("isview");
  	if(isview == null)
  	{
  		isview = "";
  	}
%>
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript">
function page_setItem(itemid)
{
    cform.itemid.value='';
    cform.itemname.value='';
    cform.umcode.value='';
    cform.umname.value='';
    if(itemid!=null)
    {
        cform.itemid.value = itemid;
        cform.itemcode.value = '';
    }
    page_handleRequest('<%=contextPath%>',cform);
}
function page_handleResponse()
{
    cform.itemid.value = getResponseData("itemid");
    cform.itemcode.value = getResponseData("itemcode");
    cform.itemname.value = getResponseData("itemname");
    cform.umcode.value = getResponseData("umcode");
    cform.umname.value = getResponseData("umname");
}
function page_add(){
    if(!checkALLElems(document.getElementById("newdetail"))) return;    
    if ((document.cform.productgroupname.value==null)||(document.cform.productgroupname.value.length <= 0)||(document.cform.productgroupname.value=="null")){
    	alert('<%=message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_ProdGroupName"))%>');
        return;
    } 
    //alert(document.cform.zmylprodgroupid.value);
    cform.actionname.value = "add";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function page_delete()
{
    if(isNullChecked(cform.deleteids))
    {
        alert('<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>');
        return;
    }
    if(!confirm('<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>')) return;
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function page_save()
{
    if(!checkALLElems(document.getElementById("olddetail"))) return;
    cform.actionname.value = "save";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function set_orgNameByPopWindow(id,code,name){
	document.cform.productgroupcode.value=code;
	document.cform.productgroupname.value=name;
	document.cform.prdgroupid.value=id;
	//alert(document.cform.zmylprodgroupid.value);
}

function setNamebycode(code){
	var  codevalue = code.value;
	var  datahandler = new  DataHandler();
	
	datahandler.add_params("productgroupcode" , codevalue,"string") ;
  	datahandler.add_params("languagecode" , 'cn',"string") ;
  	
  	datahandler.getResultFromHashMap("info" ,"prodgroupname" ,"document.cform.productgroupname");
  	datahandler.getResultFromHashMap("info" ,"prdgroupid" ,"document.cform.prdgroupid");
  	datahandler.add_job("j_getnamebycode") ;
  	
    datahandler.runDataHandler ();
}


function ProductbrandPop(){
    url = "ProductbrandPopWindow.jsp?<%= OvalTools.randomURL() %>&datacategory=9";
    attribute = "height=400, width=600,top=120,left=120,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=yes";

	popwindow = window.open(url,"newwindow", attribute);
}

</script>
<body style="overflow: auto;">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher" >
  <input type="hidden" name="pagename" value="p_contactprod">
  <input type="hidden" name="actionname">
  <input type="hidden" name="schema" value="v_zylusrofpro">
  <input type="hidden" name="empid" value="<%=usrid%>">	
  <input type="hidden" name="datacategory" value="9">
  <input type="hidden" name="userid" value="<%=Cuserinfo.get("userid")%>">	
  <input type="hidden" name="numrows" value="<%= details.size() %>">
  <input type="hidden" name="isview" value="<%=request.getParameter("isview") %>">
<table width="100%" cellspacing="0" border="0" cellpadding="0">
	<tr>
		<td>
		<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0">
		<tr class="deepblue-left"> 
          	<td width="5%" class="deepblue-left">&nbsp;</td>
          	<td width="30%" class="title_center">&nbsp;<%= label.getLabelName("L_ProdGroupCode") %></td>
	  		<td class="title_center">&nbsp;<%= label.getLabelName("L_ProdGroupName") %></td>
        </tr>
	    <span id="olddetail" >
       	<logic:iterate id="prodgroup" collection="<%= details %>" indexId="idx">
       	<tr>
         	<td width="30">
				<custom:checkbox property="employeeprdgroupid" name="prodgroup" changedName="deleteids" styleClass="normalradio" />
         	</td>
	        <td><custom:write name="prodgroup" property="productgroupcode"nbsp="true" /></td>
	        <td><custom:write name="prodgroup" property="productgroupname" nbsp="true"/></td>
    	</tr>
       	<tr>
         	<td style="display:none"><custom:hidden name="onerow" property="prdgroupid" colIndex="<%= idx %>"/></td>
        </tr>
        </logic:iterate>
		</span>
	    <%
		if(!("1".equals(isview))){
		%>
		<span id="newdetail" >
       	<tr >
         	<td>&nbsp;</td>
         	<td>
           		<!--  <custom:text name="newdetail" property="productgroupcode" style="width:80%" onchange="javascript:setNamebycode(this);"/>-->
           		<custom:text name="newdetail" property="productgroupcode" style="width:80%"/>
           		<a onclick="ProductbrandPop();">
                    		<custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
            </td>
            <td><custom:text name="newdetail" property="productgroupname" readonly="true" /><custom:hidden property="prdgroupid" /></td>    
       	</tr>
		</span>
          
		</table>
		<table width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td class="summary_top"></td>
			</tr>
			<tr>
				<td class="td_center"><a onclick="javascript:page_add();"><custom:button type="1" label="L_Add" imgsrc="finish.gif" border="0" style="width:60" /></a>
				<a onclick="javascript:page_delete();"><custom:button type="1" label="L_Delete" imgsrc="finish.gif" border="0" style="width:60" /></a></td>
			</tr>
		</table>
		<%} %>
		</td>
	</tr>
</table>

</form>
</body>
</html>